<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="Stylesheet" href="css/style.css" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" charset="utf-8">
		$(function(){
			$("select#provine").change(function(){
				$.getJSON("select.php",{id: $(this).val()}, function(j){
					var options = '';
					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("#district").html(options);
					$('#district option:first').attr('selected', 'selected');
				})				
			});
		})
	</script>
<?php require_once("connection/connect.php");?>
<style type="text/css">
<!--
.style1 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
<form name="fsearch" id="fsearch" action="results.php" method="post">
<div class="search">
                <table cellpadding="5" cellspacing="0" align="center" style="line-height: 25px">
                <tr>
                    <td colspan="6">
                    <?php 
					$numRs = mysql_num_rows(mysql_query("SELECT product_id FROM products"));
					?>
                        Có <span class="style1">[<?php echo $numRs;?>]</span> bất động sản hấp dẫn, tìm kiếm ngay!                    </td>
                </tr>
                    <tr>
                        <td rowspan="2">
                            <h4>Nhu cầu</h4>
                            <select id="need" name="need" class="select">
                                <option value="" selected="selected">Chọn loại</option>
                                <option value='1'>Bán</option>
                                <option value='2'>Cho thuê</option>
                                <option value='3'>Cần thuê</option>
                                <option value='4'>Sang nhượng</option>
                            </select>
                         </td>
                        <td rowspan="2">
                            <h4>Mục đích</h4>
                            <select id="purpose" name="purpose" class="select">
                                <option value="" selected="selected">Chọn mục đích</option>
                                <option value='1'>Nhà ở</option>
                                <option value='2'>Kinh doanh</option>
                                <option value='3'>Buôn bán</option>
                                <option value='4'>Đất trống</option>
                            </select>
                        </td>
                        <td rowspan="2">
                            <h4>Danh mục</h4>
                                <select name="category" class="select">
                                <option value="">Chọn danh mục</option>
                                <?php
								$rs = mysql_query("select cat_id, name from categories");
								while($d = mysql_fetch_array($rs)){
								?>
                                <option value='<?php echo $d['cat_id'];?>'><?php echo $d['name'];?></option>
                                <?php }?>
                            </select>
                        </td>
                        <td rowspan="2">
                            <h4>
                                Tỉnh/thành phố</h4>
                            <select id="provine" name="provine">
        						<option value="">Chọn Tỉnh/Thành Phố</option>
        <?php
		$rs = mysql_query("select provine_id, name from provines");
		while($d = mysql_fetch_array($rs)){
		?>
								<option value="<?php echo $d['provine_id'];?>"><?php echo $d['name'];?></option>
        <?php } ?>
							</select>
                        </td>
                        <td rowspan="2">
                            <h4>
                                Quận/huyện</h4>
                            <select id="district" name="district" class="select">
                                <option value="" selected="selected">Chọn quận/huyện</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: center">
                            <a id="displayText" href="javascript:toggle();">Hiện lựa chọn tìm kiếm</a>
                        </td>
                    </tr>
                </table>
                <div id="toggleText" style="display: none">
                    <table cellpadding="5" cellspacing="0" align="center" style="line-height: 25px">
                        <tr>
                            <td>
                                <h4>
                                    Giá từ</h4>
                                    <input id="priceMin" name="priceMin" type="text"/>
                            </td>
                            <td>
                                <h4>
                                    đến</h4>
                                    <input id="priceMax" name="priceMax" type="text"/>
                            </td>
                            <!-- lam khi xong modul ti gia 
                            <td>
                                <h4>
                                    Loại tiền</h4>
                                <select id="Select7" name="D7" class="select">
                                    <option value="" selected="selected">-- Chọn --</option>
                                    <option value='10'>VNĐ</option>
                                    <option value='10'>JSC</option>
                                    <option value='10'>USD</option>
                                </select>
                            </td>
                            -->
                            <td>
                                <h4>
                                    Diện tích</h4>
                                    <input id="area" name="area" type="text"/>
                            </td>
                            <td>
                                <h4>
                                    Hướng nhà</h4>
                                <select id="orientation" name="orientation" class="select">
                                                <option>Chọn hướng nhà</option>
                                            
                                                    <option value="1">Đông</option>
                                                    <option value="1">Tây</option>
                                                    <option value="1">Nam</option>
                                                    <option value="1">Bắc</option>
                                            
                              </select>
                            </td>
                            <td>
                                <h4>
                                    Số phòng khách</h4>
                                <select id="livingroom" name="livingroom" class="select">
                                    <option value="" selected="selected">-- Chọn --</option>
                                    <option value='1'>1+</option>
                                    <option value='2'>2+</option>
                                    <option value='3'>3+</option>
                                </select>
                            </td>
                            <td>
                                <h4>
                                    Số phòng ngủ</h4>
                                <select id="bedroom" name="bedroom" class="select">
                                    <option value="" selected="selected">-- Chọn --</option>
                                    <option value='1'>1+</option>
                                    <option value='2'>2+</option>
                                    <option value='3'>3+</option>
                                </select>
                            </td>
                            <td>
                                <h4>
                                    Số phòng tắm</h4>
                               <select id="bathroom" name="bathroom" class="select">
                                    <option value="" selected="selected">-- Chọn --</option>
                                    <option value='1'>1+</option>
                                    <option value='2'>2+</option>
                                    <option value='3'>3+</option>
                                </select>
                            </td>
                            <td align="center" valign="bottom">
                                <input id="full_comfortable" name="full_comfortable" type="checkbox" />Đầy đủ tiện nghi
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="text-align: right">
                    <input id="btnSearch" name="btnSearch" type="submit" class="button" value="Tìm trong Sànnhàở.com" />
               </div>
            </div>
            </form>